﻿#region << 版 本 注 释 >>
/*----------------------------------------------------------------
// Copyright (C) 2022 kingerrobot
// 版权所有。 
//
// 文件名：BWcsNetInCuring
// 文件功能描述：
//
// 创建者：名字 (zzl)
// 时间：2022/1/20 16:51:18
//
// 修改人：
// 时间：
// 修改说明：
// 版本：V1.0.0
//----------------------------------------------------------------*/
#endregion
using System;

namespace KingerRobot.MexicoSailunMDC.SpiService;

internal class BWcsNetInCuring : IWcsNetInCuring
{
    public POWcsNetInCuring GetWcsNetinCuringByPickupId(long pickupId)
    {
        var db = Db.Default;
        var result = db.WcsNetInCurings
            .Where(t => t.PickupId1 == pickupId || t.PickupId2 == pickupId)
            .FirstOrDefault();
        return result;
    }
    public POWcsNetInCuring GetWcsNetinCuringByTranLoc(long locId)
    {
        var db = Db.Default;
        var result = db.WcsNetInCurings
            .Where(t => t.TranLoc == locId)
            .FirstOrDefault();
        return result;
    }
    public POWcsNetInCuring GetWcsNetinCuringByScanLoc(long locId)
    {
        var db = Db.Default;
        var result = db.WcsNetInCurings
            .Where(t => t.ScannerLoc == locId)
            .FirstOrDefault();
        return result;
    }

    public int UpdateWcsNetinCuring(long locId, string barCode, int taskNo)
    {
        var db = Db.Default;
        var inCuring = db.WcsNetInCurings.Where(t => t.ScannerLoc == locId).FirstOrDefault();
        inCuring.ErrBarcode = barCode;
        inCuring.ErrTaskNo = taskNo;
        inCuring.UpdateTime = DateTime.Now;
        var result = db.SaveChanges();
        return result;
    }
}